﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="lefter.ascx.cs" Inherits="AiLuWeb.WebSite.UC.lefter" %>
<%@ Import Namespace="System.Linq" %>
<% 
    switch (CurrentNavType)
    {
        case NavigationType.About: 
            lanMuInfoList = AiLuWeb.WebSite.Code.Utility.GetParentLanMu(1);
%>
<table border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <img src="/images/8.gif" width="230" height="59" alt="关于我们"/>
        </td>
    </tr>
    <tr>
        <td height="335" align="center" valign="top" background="/images/9.gif">
            <% 
                foreach (var item in lanMuInfoList)
                {
            %>
            <table width="183" height="36" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center" background="/images/11.gif" style="padding-right: 20px;" class="left_dh">
                        <strong><a href="/lanmu.aspx?id=<%=item.Id%>"><%=item.Name%></a></strong>
                    </td>
                </tr>
            </table>
            <% 
                }        
            %>
        </td>
    </tr>
</table>
<%
            break;
        case NavigationType.Product:
%>
<table border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <img src="/images/84.gif" width="230" height="59" alt="产品中心"/>
        </td>
    </tr>
    <tr>
        <td height="335" align="center" valign="top" background="/images/9.gif">
            <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="left" > 
                        <ul id="root">
                            <% 
                              var productClass = AiLuWeb.WebSite.Code.Utility.GetNewsClass().Where(c => c.PId == 15);
                              foreach (var item1 in productClass)
                              {
                            %>
                            <li>
                                <a href="/productscate.aspx?id=<%=item1.Id %>">
                                    <label> <%=item1.Name%></label>
                                </a>
                                <ul id="ul<%=item1.Id %>" class="two">
                                    <% 
                                      foreach (var item2 in AiLuWeb.WebSite.Code.Utility.GetNewsClass().Where(c => c.PId == item1.Id))
                                      {
                                    %>
                                    <li>
                                        <a href="/productlist.aspx?id=<%=item2.Id %>">
                                            <label> <%=item2.Name%></label>
                                        </a>
                                        <ul id="ul<%=item2.Id %>" class="two">
                                            <% 
                                          if (ProductCId > 0 && item2.Id == ProductCId)
                                          { 
                                             System.Collections.Generic.IList<AiLuWeb.Model.Products> curList= AiLuWeb.WebSite.Code.Utility.GetProductsByCid(ProductCId);
                                             foreach (var pro in curList)
                                              {
                                            %>
                                            <li>
                                                <a href="/productinfo.aspx?id=<%=pro.Id %>"><%=pro.Title%></a>
                                            </li>
                                            <% 
                                              }
                                          }
                                            %>
                                        </ul>
                                    </li>
                                    <% 
                                        }    
                                    %>
                                </ul>
                            </li>
                            <% 
                              }    
                            %>
                        </ul>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<script type="text/javascript">
       
    //面向对象方法
    var Tree = function (o) {
        this.root = document.getElementById(o);
        this.labels = this.root.getElementsByTagName('label');
        var that = this;
        this.int();
        Tree.prototype.addEvent(this.root, 'click', function (e) { that.treeshow(e) });
    }
    Tree.prototype = {
        int: function () {//初始化页面，加载时给有孩子结点的元素动态添加图标
            for (var i = 0; i < this.labels.length; i++) {
                var span = document.createElement('span');
                span.style.cssText = 'display:inline-block;height:18px;vertical-align:middle;width:16px;cursor:pointer;';
                span.innerHTML = ' '
                span.className = 'add';
                    this.labels[i].parentNode.insertBefore(span, this.labels[i]);
            }
        },
        treeshow: function (e) {
            e = e || window.event;
            var target = e.target || e.srcElement;
            var tp = this.nextnode(target.parentNode.nextSibling);
            switch (target.nodeName) {
                case 'A': //点击A标签展开和收缩树形目录，并改变其样式
                    if (tp && tp.nodeName == 'UL') {
                        if (tp.style.display != 'block') {
                            tp.style.display = 'block';
                            this.prevnode(target.parentNode.previousSibling).className = 'ren'
                        } else {
                            tp.style.display = 'none';
                            this.prevnode(target.parentNode.previousSibling).className = 'add'
                        }
                    }
                    break;
                case 'SPAN': //点击图标只展开或者收缩
                    var ap = this.nextnode(this.nextnode(target.nextSibling).nextSibling);
                    if (ap.style.display != 'block') {
                        ap.style.display = 'block';
                        target.className = 'ren'
                    } else {
                        ap.style.display = 'none';
                        target.className = 'add'
                    }
                    break;
            }
        },
        addEvent: function (el, name, fn) {//绑定事件
            if (el.addEventListener) return el.addEventListener(name, fn, false);
            return el.attachEvent('on' + name, fn);
        },
        nextnode: function (node) {//寻找下一个兄弟并剔除空的文本节点
            if (!node) return;
            if (node.nodeType == 1)
                return node;
            if (node.nextSibling)
                return this.nextnode(node.nextSibling);
        },
        prevnode: function (node) {//寻找上一个兄弟并剔除空的文本节点
            if (!node) return;
            if (node.nodeType == 1)
                return node;
            if (node.previousSibling)
                return prevnode(node.previousSibling);
        }
    }
    tree = new Tree("root"); //实例化应用
</script> 
<%
            break;
        case NavigationType.News:
%>
<table border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <img src="/images/82.gif" width="230" height="59" alt="新闻中心"/>
        </td>
    </tr>
    <tr>
        <td height="335" align="center" valign="top" background="/images/9.gif">
            <% 
                var newClass = AiLuWeb.WebSite.Code.Utility.GetNewsClass().Where(c => c.PId == 1);
                foreach (var item in newClass)
                {
                                            
            %>
            <table width="183" height="36" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center" background="/images/11.gif" style="padding-right: 20px;" class="left_dh">
                        <strong><a href="/newslist.aspx?id=<%=item.Id %>"><%=item.Name %></a></strong>
                    </td>
                </tr>
            </table>
            <%
                } 
            %>
        </td>
    </tr>
</table>
<%
            break;
        case NavigationType.Brand:
            lanMuInfoList = AiLuWeb.WebSite.Code.Utility.GetParentLanMu(2);
%>
<table border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <img src="/images/81.gif" width="230" height="59" alt="品牌专区"/>
        </td>
    </tr>
    <tr>
        <td height="335" align="center" valign="top" background="/images/9.gif">
            <% 
                foreach (var item in lanMuInfoList)
                {
            %>
            <table width="183" height="36" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center" background="/images/11.gif" style="padding-right: 20px;" class="left_dh">
                        <strong><a href="/lanmu.aspx?id=<%=item.Id%>"><%=item.Name%></a></strong>
                    </td>
                </tr>
            </table>
            <%
                } 
            %>
        </td>
    </tr>
</table>
<%
            break;
        case NavigationType.MyJob:
%>
<table border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <img src="/images/85.gif" width="230" height="59" alt="虚位以待"/>
        </td>
    </tr>
    <tr>
        <td height="335" align="center" valign="top" background="/images/9.gif">
            <table width="183" height="36" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center" background="/images/11.gif" style="padding-right: 20px;" class="left_dh">
                        <strong><a href="/myjoblist.aspx">虚位以待</a></strong>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<%
            break;
        case NavigationType.Link:
            lanMuInfoList = AiLuWeb.WebSite.Code.Utility.GetParentLanMu(4);
%>
<table border="0" cellspacing="0" cellpadding="0">
    <tr>
        <td>
            <img src="/images/86.gif" width="230" height="59" alt="联系我们"/>
        </td>
    </tr>
    <tr>
        <td height="335" align="center" valign="top" background="/images/9.gif">
            <% 
                foreach (var item in lanMuInfoList)
                {
            %>
            <table width="183" height="36" border="0" cellpadding="0" cellspacing="0">
                <tr>
                    <td align="center" background="/images/11.gif" style="padding-right: 20px;" class="left_dh">
                        <strong><a href="/lanmu.aspx?id=<%=item.Id%>"><%=item.Name%></a></strong>
                    </td>
                </tr>
            </table>
            <% 
                }        
            %>
        </td>
    </tr>
</table>
<%
            break;
    }    
%>